package com.mdb.open.trade.service.trade;


/*
* Copyright (C), 2017-2019 澳发科技(MDB)
* FileName: TfLoanRemittanceService.java
* Author:   you.yichao
* Date:     2019-07-30
* History:
* <author>          <time>          <version>          <desc>
* you.yichao         2019-07-30          V1.00             代码生成器初始生成代码
* -----------------------------------------------------------
* 作者姓名           修改时间           版本号            描述
*/


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mdb.bc.database.mybatisplus.PageUtil;
import com.mdb.bc.database.mybatisplus.SuperService;
import com.mdb.bc.utils.ObjectUtil;
import com.mdb.open.common.enums.trade.status.LoanRemitStatusEnum;
import com.mdb.open.common.enums.trade.status.OutwardRemitStatusEnum;
import com.mdb.open.trade.common.MdbDataSource;
import com.mdb.open.trade.domain.bo.trade.QueryLoanRemitPageListBo;
import com.mdb.open.trade.domain.po.trade.LoanRemittance;
import com.mdb.open.trade.mapper.trade.TfLoanRemittanceMapper;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

/**
 * 类描述：
 *  放款流水表 服务类
 *
 * @author you.yichao
 * @date 2019-07-30
 */
@Service
@Log4j2
@DS(MdbDataSource.TRADE)
public class TfLoanRemittanceService extends SuperService<TfLoanRemittanceMapper, LoanRemittance> {

    /**
     * 分页查询
     * @param bo
     * @return
     */
    public IPage<LoanRemittance> pageQuery(QueryLoanRemitPageListBo bo) {

        LambdaQueryWrapper<LoanRemittance> queryWrapper = new LambdaQueryWrapper<>();

        if (ObjectUtil.isNotEmpty(bo.getBusinessNo())) {
            queryWrapper.eq(LoanRemittance::getBusinessNo, bo.getBusinessNo());
        }
        if (ObjectUtil.isNotEmpty(bo.getApplyOrderNo())) {
            queryWrapper.eq(LoanRemittance::getApplyOrderNo, bo.getApplyOrderNo());
        }
        if (ObjectUtil.isNotEmpty(bo.getCustomerCode())) {
            queryWrapper.eq(LoanRemittance::getCustomerCode, bo.getCustomerCode());
        }
        if (ObjectUtil.isNotEmpty(bo.getFileStatus())) {
            queryWrapper.eq(LoanRemittance::getPayFileStatus, bo.getFileStatus());
        }
        if (ObjectUtil.isNotEmpty(bo.getStartDate()) && ObjectUtil.isNotEmpty(bo.getEndDate())) {
            queryWrapper.between(LoanRemittance::getOutwardDate, bo.getStartDate(), bo.getEndDate());
        }
        if (ObjectUtil.isNotEmpty(bo.getReceiveAcc())) {
            queryWrapper.eq(LoanRemittance::getReceiveAcc, bo.getReceiveAcc());
        }
        queryWrapper.eq(LoanRemittance::getStatus, LoanRemitStatusEnum.SUCCESS);
        queryWrapper.eq(LoanRemittance::getOutStatus, OutwardRemitStatusEnum.SUCCESS);

        return this.baseMapper.selectPage(PageUtil.initPage(bo), queryWrapper);

    }

}
